<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    请输入年份：<input type="text" class="a"><br>
    请输入月份：<input type="text" class="b"><br>
    请输入当月的日期：<input type="text" class="c"><br>
    <button class="button">点击可以查看今天是一年中的第几天</button>
    <script>
        // 根据输入的三个数字，判断是这一年的第几天,  先判断是闰年还是平年，
        var year = document.getElementsByClassName("a")[0];
        var month = document.getElementsByClassName("b")[0];
        var day = document.getElementsByClassName("c")[0];
        var anwser = document.getElementsByClassName("button")[0];
        anwser.onclick = function () {
                var getyear = parseFloat(year.value) % 4;
                var getmonth =parseFloat(month.value);
                var getday =parseFloat(day.value);
                switch (getyear) {
                    case 0:
                        switch (getmonth) {
                            case 1:
                                alert(getday);
                                break
                            case 2:
                                alert(getday+31);
                                break
                            case 3:
                                alert(getday+60);
                                break
                            case 4:
                                alert(getday+91);;
                                break
                            case 5:
                                alert(getday+121);
                                break
                            case 6:
                                alert(getday+152);
                                break
                            case 7:
                                alert(getday+182);
                                break
                            case 8:
                                alert(getday+213);
                                break
                            case 9:
                                alert(getday+244);
                                break
                            case 10:
                                alert(getday+274);
                                break
                            case 11:
                                alert(getday+305);
                                break
                            case 12:
                                alert(getday+335);
                                break
                        }
                    default:
                        switch (getmonth) {
                            case 1:
                                    alert(31 - day)
                                break
                            case 2:
                                    alert(59 - day)
                                break
                            case 3:
                                    alert(90 - day)
                                break
                            case 4:
                                    alert(120 - day)
                                break
                            case 5:
                                    alert(151 - day)
                                break
                            case 6:
                                    alert(181 - day)
                                break
                            case 7:
                                    alert(212 - day)
                                break
                            case 8:
                                    alert(243 - day)
                                break
                            case 9:
                                    alert(273 - day)
                                break
                            case 10:
                                    alert(304 - day)
                                break
                            case 11:
                                    alert(334 - day)
                                break
                            case 12:
                                    alert(365 - day)
                                break
                            }
                }
            }
    </script>
</body>

</html>